-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Structured metadata: Refactor into new variable #826
Conversation
…ds selection buggy
…getPrimaryLabelFromUrl
…service-selection-any-label-tabs
…election-any-label-tabs
key: string, | ||
value: string, | ||
sceneRef: SceneObject | ||
): VariableFilterType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's something very odd with this function. type
can be null, or have a value; independent of the type, we check for getParserForField()
, which supports only structuredMetadata
, so it can return something else, or nothing, but type can also be null, which goes to the default case.
I think we should refactor this before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion:
- Make type non-null
- In the consumer side of these functions, if there is no type to pass, then use
getParserForField()
, or other function, instead ofgetFilterTypeFromLabelType()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I fully understood, how does this look? b643f48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just one comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great job!
Just a nit, might also be interesting for @matyax:
When filtering for structured metadata the logs panel filter button state is not updated accordingly. Maybe Matias knows best where to adjust that.
Taking a look. |
Yeah, great catch. We need to update https://github.com/grafana/explore-logs/blob/main/src/Components/ServiceScene/LogsPanelScene.tsx#L125-L176 |
@svennergr @matyax Good catch, that bug has likely been hanging out since we added detected_fields. Should be fixed now in b643f48 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 🇮🇹
This PR moves structured metadata fields into a dedicated scenes variable.
This enables us to have more control over how metadatafields are interpolated in the query, allowing us to place all metadata before any log parsers, which will result in more efficient/optimal queries.
There should be no changes to the UI, just the queries that are sent to Loki.
We still have a potential race condition where users can filter results in the table/logs panel before the detected_fields response which will give us the parser, in these cases we will fall back to adding fields with "unknown" parsers to the fields variable, and require both logfmt and json parsers for queries with that field. Created #837 to track